package com.example.quanly;

import android.widget.ArrayAdapter;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.os.Bundle;

public class MyArrayAdapter extends ArrayAdapter<Employee> {
	Activity context = null;
	ArrayList<Employee>MyArray = null;
	int layoutID;
	public MyArrayAdapter(Activity context, int layoutID,ArrayList<Employee>arr ) {
		super(context, layoutID, arr);
		this.context= context;
		this.layoutID= layoutID;
		this.MyArray = arr;
		// TODO Auto-generated constructor stub
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		LayoutInflater inflater= context.getLayoutInflater();
		convertView = inflater.inflate(layoutID, null);
		if(MyArray.size()>0 && position>=0){
			// lay textview ra e hien thi Ma va ten
			final TextView txtdisplay=(TextView)convertView.findViewById(R.id.txtitem);
			// lay ra nhan vien o vi tri position
			final Employee emp = MyArray.get(position);
			// tra ve thong tin
			txtdisplay.setText(emp.toString());
			final ImageView imgitem=(ImageView) convertView.findViewById(R.id.imgitem);
			imgitem.setImageResource(R.drawable.edit);
		}
		return convertView;
	}
	
}
